<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta name="author" content="mengxiangzhong">
		<title>圈提</title>
		<script language="javascript" type="text/javascript" src="../script/print.js"></script>
		<script language="javascript" src="../script/common.js" type="text/javascript"></script>
		<script language="javascript" src="../script/card.js" type="text/javascript"></script>
		<script language="javascript" type="text/javascript">
			var Page;
			function initPageElements(){
				Common.initDict(Page.operationForm.accCode,TX.AccountType.cardTx());
				Page.changeAccCode = function(){
					Page.operationForm.amount.value = "";
				}
				Page.checkAuthority = function(result){
					if (Page.raw.card.grayFund || Page.raw.card.grayPoint){
						showWarning("卡片被灰锁，请先进行解灰操作。");
						return false;
					}
					return true;
				}
				Page.bill = 'load_bill';
				Page.preResult = function(result){
					showInformation("圈提成功");
				}
			}

			function cardUnLoadFunc(){
				if (!Page.raw || !Page.raw.card){
					showWarning("请先读卡");
					return;
				}
				if(!checkForm(Page.operationForm.id))
					return;
				var data = Common.getValues(Page.operationForm);
				if (TX.Misc.greaterThan(data.amount,data.cardBalance)){
					showWarning("卡帐户余额不足，无法圈提");
					return;
				}
				var confirmString =   "圈提卡号:" + Page.raw.card.asn + TX.SHOW_INFO_LINEBREAK
									+ "帐户类型:" + Common.getText('account_type',data.accCode) + TX.SHOW_INFO_LINEBREAK
									+ "帐户单位:" + data.unit + TX.SHOW_INFO_LINEBREAK
									+ "圈 提 额:" + data.amount + TX.SHOW_INFO_LINEBREAK;
				if (showQuestion(confirmString)){
					Page.operation.disabled = true;
					try{
						var trade = cardUnload(Page.raw.card.asn,
									Page.amountInSystem(data.amount),
									data.accCode,
									Page.options.tradeDate,
									Page.raw.card.pin,
									null,
									null)
						TX.Trade.showResult(trade);
					}catch(e){
						showError(e.description);
						//Page.operation.disabled = true;
					}
				}
			}
		</script>
	</head>
	<body onload="TX.Trade.init();">
		<div class="nav"><div id="nav">&nbsp;</div></div>
		<div id="operationFormDiv">
			<form id="operationForm" name="operationForm">
				<div class="form">
					<div class="formTitle">
						卡片信息
					</div>
					<span id="readonlyInfo"></span>
				</div>
				<div class="form">
				<div class="formTitle">圈提信息</div>
					<table cellSpacing="0" cellPadding="4" width="100%" border="0" class="col2 label8">
						<tr>
							<td><label>帐户类型</label> <select name="accCode" onchange="TX.Trade.changeAccCode(this);"></select><span class="des">*</span></td>
						 	<td><label>圈 提 额</label> <input type="text" name="amount" onblur="Page.amountValidator(this)"><span class=des>*</span></td>
						</tr>
					</table>
				</div>
				<p>
					<button onclick="TX.Trade.ReadCard()">读 卡</button>
					<button name="operation" onclick="cardUnLoadFunc()" >圈 提</button>
					<button onclick="TX.Trade.reset()">重 置</button>
				</p>
			</form>
		</div>
	
		<div id="printSheetDiv" style="display:none;">
			<div class="form">
				<div class="formTitle">圈提明细</div>
				<div id="mainTrade"></div>
			</div>
			<div class="form" id="subTradesDiv" style="display:none;">
				<div class="formTitle">
					<span id="subTradesTitle"></span>
				</div>
				<div id="subTradesList"></div>
			</div>
			<p>
				<button onclick="TX.Trade.goFirstPage()">返 回</button>
			</p>
		</div>
		<div id="billDiv" class="form" width="100% " style="display:none;">
			<div class="formTitle">
				<div class="l">交易凭证</div>
				<div class="r">
					<button onclick="WebPrint.preview('content')">打印预览</button>
			 		<button onclick="WebPrint.print('content')">打印</button>
			 		<button onclick="TX.Trade.goFirstPage()">返 回</button>
				</div>
			</div>
			<div  id="content"  align='center'></div>
		</div>
	</body>
</html>